<template>
  <view class="my-container">
    <my-login v-if="!hasLogin" @loginSuccess="handleLoginSuccess"></my-login>
    <my-userinfo v-else :userinfo="userinfo"></my-userinfo>
  </view>
</template>

<script>
import { mapState, mapActions } from 'vuex'

export default {
  
  data() {
    return {
      
    };
  },
  computed: {
    ...mapState('m_user', ['hasLogin', 'userinfo'])
  },
  onLoad() {
    // 页面加载时初始化登录状态
    this.initLoginStatus();
  },
  onShow() {
    // 确保每次显示页面时都检查登录状态
    this.initLoginStatus();
  },
  methods: {
    ...mapActions('m_user', ['initLoginStatus']),
    handleLoginSuccess() {
      // 登录成功后的回调
      console.log('登录成功，切换到用户信息页面');
    }
  }
}
</script>

<style lang="scss">
  page,
  .my-container {
    height: 100%;
  }
</style>